import { addEvent } from '@/utils/utils';
import { App } from "vue";

export let clickoutside = (app: App) => {
    app.directive('clickoutside', {
        beforeMount(el, binding) {
            addEvent(document, "click", (e: MouseEvent) => {
                if (!el.contains(e.target)) {
                    binding.value()
                }
            })
        },
        unmounted() {
            document.removeEventListener('click', () => { })
        }
    })
}